#-*- coding: utf-8 -*-
#! /usr/bin/python

import sys
import ConfigParser
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait

def loginTb(username,password):
    '''
    jhfnetboy@gmail.com create to login taobao
    '''
    #chrome.delete_all_cookies()
    lgurl = 'https://login.taobao.com/member/login.jhtml'
    chrome.get(lgurl)
    #set username and password
    try:
        chrome.find_element_by_class_name('nickx').click()
    except:
        pass
    try:
        #chrome.execute_script("document.getElementByName('TPL_username').value = '11'")
        #uname = WebDriverWait(chrome, 10).until(lambda chrome : chrome.find_element_by_name("TPL_username"))
        #uname = WebDriverWait(chrome, 10).until(lambda chrome : chrome.find_element_by_id("TPL_username_1"))
        uname = chrome.find_element_by_id("TPL_username_1")
        uname.send_keys(username.decode('utf-8'))
    except:
        print 'fail to get element TPL_username'

url = 'https://login.taobao.com/member/login.jhtml'
chrome = webdriver.Chrome()
loginTb('长胡子的小羊','sdf')